package com.thoughtworks.merchantsguide;

import com.thoughtworks.merchantsguide.cache.ComodityPriceCache;
import com.thoughtworks.merchantsguide.exception.InvalidCommodityException;
import com.thoughtworks.merchantsguide.exception.InvalidInputException;
import com.thoughtworks.merchantsguide.exception.UnsupportedNumberException;
import com.thoughtworks.merchantsguide.processor.CommodityPriceProcessor;
import com.thoughtworks.merchantsguide.processor.CustomerQueryProcessor;
import com.thoughtworks.merchantsguide.processor.GalacticNumberGrammarProcessor;
import com.thoughtworks.merchantsguide.processor.LineProcessor;

/**
 * Hello world!
 *
 */
public class App 
{
	public static void main(String[] args) throws Exception
    {
		testMethod();
    }

	/**
	 * @throws InvalidInputException
	 * @throws UnsupportedNumberException
	 * @throws InvalidCommodityException
	 */
	private static void testMethod() throws InvalidInputException, UnsupportedNumberException,
			InvalidCommodityException {
		LineProcessor firstProcessor = new GalacticNumberGrammarProcessor();
		String testStr = "glob is I";
		firstProcessor.process(testStr);
		testStr = "prok is V";
		firstProcessor.process(testStr);
		testStr = "pish is X";
		firstProcessor.process(testStr);
		testStr = "tegj is L";
		firstProcessor.process(testStr);
		
		System.out.println(ComodityPriceCache.getInstance().getSupportedNumberSystem());

		
		LineProcessor commodityPriceProcessor = new CommodityPriceProcessor();
		testStr ="pish pish Iron is 3910 Credits";
		commodityPriceProcessor.process(testStr);
		testStr = "glob glob Silver is 34 Credits";
		commodityPriceProcessor.process(testStr);
		testStr ="glob prok Gold is 57800 Credits";
		commodityPriceProcessor.process(testStr);
		System.out.println(ComodityPriceCache.getInstance().getListOfSupportedMatter());

		
		LineProcessor customerQueryProcessor = new CustomerQueryProcessor();
		testStr = "how much is pish tegj glob glob ?";
		customerQueryProcessor.process(testStr);
		testStr = "how many Credits is glob prok Silver ?";
		customerQueryProcessor.process(testStr);
		testStr = "how many Credits is glob prok Gold ?";
		customerQueryProcessor.process(testStr);
		testStr = "how many Credits is glob prok Iron ?";
		customerQueryProcessor.process(testStr);
		testStr = "how much wood could a woodchuck chuck if a woodchuck could chuck wood ?";
		customerQueryProcessor.process(testStr);
	}
}
